import { computed, inject, toRef } from "vue";

import context from "../components/arco-form/context";
export const useFormItem = ({ size, disabled, error, uninject } = {}) => {
  const formItemCtx = !uninject ? inject(context.formItemInjectionKey, {}) : {};
  const mergedSize = computed(() => {
    let _a;
    return (_a = size == null ? void 0 : size.value) != null
      ? _a
      : formItemCtx.size;
  });
  console.log(disabled.value, "我嘿嘿一笑");
  const mergedDisabled = computed(
    () => (disabled == null ? void 0 : disabled.value) || formItemCtx.disabled,
  );
  const mergedError = computed(
    () => (error == null ? void 0 : error.value) || formItemCtx.error,
  );
  const feedback = toRef(formItemCtx, "feedback");
  const eventHandlers = toRef(formItemCtx, "eventHandlers");
  return {
    formItemCtx,
    mergedSize,
    mergedDisabled,
    mergedError,
    feedback,
    eventHandlers,
  };
};
